package com.vvitt.kotlinhiltcarhome.di

import android.app.Application
import androidx.room.Room
import com.vvitt.kotlinhiltcarhome.db.CarBrandDao
import com.vvitt.kotlinhiltcarhome.db.CarBrandDataBase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ApplicationComponent
import javax.inject.Singleton

/**
 * @author please call me police uncel
 * @since 2023/5/26
 * @email 110
 * @desciption Room module 自动注入
 **/
@InstallIn(ApplicationComponent::class)
@Module
object RoomModule {

    @Singleton
    @Provides
    fun provideCarBrandDataBase(application: Application): CarBrandDataBase {
        return Room.databaseBuilder(application, CarBrandDataBase::class.java, "vvitt_car_home.db")
            .build()
    }

    @Singleton
    @Provides
    fun provideCarBrandDao(database: CarBrandDataBase): CarBrandDao {
        return database.carBrandDao()
    }
}
